﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CategoryView.ascx.cs" Inherits="Thuoc24h.AdminCP.Controls.CategoryView" %>
<%@ Import Namespace="Thuoc24h.Common" %>
<asp:HiddenField runat="server" ID="hdfType"/>
<Telerik:RadGrid runat="server" AutoGenerateColumns="False" ID="gridData" CellSpacing="0" GridLines="None" DataSourceID="CategoryEds"
    AllowPaging="True" AllowCustomPaging="True" OnItemCommand="gridData_ItemCommand" AllowSorting="True" OnPreRender="gridData_PreRender">
    <MasterTableView ClientDataKeyNames="Id" DataKeyNames="Id" GroupLoadMode="Client" CommandItemDisplay="Top"
        PageSize="20" NoMasterRecordsText="Không có bản ghi nào.">
        <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Thêm mới" RefreshText="Tải lại" ShowAddNewRecordButton="True" ShowRefreshButton="True"></CommandItemSettings>
        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>

        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <GroupByExpressions>
            <%-- <Telerik:GridGroupByExpression>
                <SelectFields>
                    <Telerik:GridGroupByField FieldAlias="ParentId" FieldName="Name"></Telerik:GridGroupByField>
                </SelectFields>
                <GroupByFields>
                    <Telerik:GridGroupByField FieldName="Name"></Telerik:GridGroupByField>
                </GroupByFields>
            </Telerik:GridGroupByExpression>--%>
        </GroupByExpressions>
        <Columns>
            <Telerik:GridTemplateColumn HeaderText="STT" UniqueName="Id">
                <ItemStyle HorizontalAlign="Left" CssClass="center" />
                <ItemTemplate>
                    <%#
                   (gridData.PageSize * (gridData.CurrentPageIndex + 1)) - gridData.PageSize + Container.ItemIndex + 1
                    %>
                </ItemTemplate>
                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="50px" />
            </Telerik:GridTemplateColumn>
            <Telerik:GridTemplateColumn HeaderText="Name" UniqueName="Name">

                <ItemTemplate>
                    <%# Eval("Name") %>
                </ItemTemplate>
                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Left" />
            </Telerik:GridTemplateColumn>

            <Telerik:GridTemplateColumn HeaderText="Nhóm" UniqueName="ParentName">

                <ItemTemplate>
                    <%--  <%# Eval("ParentName") %>--%>
                </ItemTemplate>
                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Left" />
            </Telerik:GridTemplateColumn>
            <Telerik:GridTemplateColumn HeaderText="Thứ tự" UniqueName="Order">

                <ItemTemplate>
                    <%# Eval("SortOrder") %>
                </ItemTemplate>
                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Left" Width="50" />
            </Telerik:GridTemplateColumn>


            <Telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" ConfirmDialogType="RadWindow"
                HeaderText="Sửa"
                Text="Sửa" UniqueName="Edit">
                <ItemStyle CssClass="center" Width="32px" />
                <HeaderStyle HorizontalAlign="Center" Width="32px" Font-Bold="True" />
            </Telerik:GridButtonColumn>
            <Telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow"
                ConfirmText="Bạn có chắc chắn muốn xóa" ConfirmTitle="Xóa" HeaderText="X&#243;a"
                Text="X&#243;a" UniqueName="Delete">
                <ItemStyle CssClass="center" Width="32px" />
                <HeaderStyle HorizontalAlign="Center" Width="32px" Font-Bold="True" />
            </Telerik:GridButtonColumn>
        </Columns>

        <EditFormSettings EditFormType="Template">
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>

        </EditFormSettings>

    </MasterTableView>
    <ClientSettings EnableRowHoverStyle="True">
        <%--<Resizing AllowColumnResize="True" />--%>
        <%--  <ClientEvents OnRowDblClick="RowDblClick" />
        <ClientEvents OnRowSelected="RowDblClick" />--%>
    </ClientSettings>
    <FilterMenu EnableImageSprites="False"></FilterMenu>

    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>


</Telerik:RadGrid>

<asp:EntityDataSource runat="server" ID="CategoryEds" ConnectionString="name=MedLifeDataContext" DefaultContainerName="MedLifeDataContext" EnableFlattening="False" EntitySetName="Categories" Select="it.[Name], it.[Id], it.[SortOrder], it.[ParentId]" AutoGenerateWhereClause="True" OrderBy="it.[Id] DESC"  EntityTypeFilter="" Where="">
    <OrderByParameters>
        <asp:Parameter Name="Id" DefaultValue="" Type="Int32" />
    </OrderByParameters>
    <WhereParameters>
        <asp:ControlParameter ControlID="hdfType" Name="CategoryType" PropertyName="Value" Type="Int32" />
    </WhereParameters>
</asp:EntityDataSource>
